import React from 'react'
import ReactDOM from 'react-dom'
import { Link } from 'react-router'

import Nav from "./nav/nav"
import Footer from "./footer/footer"

import styles from "./main.css"

const Main = React.createClass({
    contextTypes: {
        router: React.PropTypes.object.isRequired
    },
    verify() {
        if (this.context.router.isActive("login") || this.context.router.isActive("register"))
            return
        // if (!localStorage['swallow_token'])
        //     this.context.router.push("login")
    },
    componentWillUpdate() {
        this.verify()
    },
    componentWillMount() {
        this.verify()
    },
    verifyRoute() {
        if (this.props.location.pathname == "/")
            this.context.router.push("appear")
    },
    componentDidUpdate() {
        this.verifyRoute()
    },
    componentDidMount() {
        this.verifyRoute()
    },
    render() {
        return (
            <div id="main">
                <Nav />
                <div id={styles.content}>
                    {this.props.children}
                </div>
                <Footer />
            </div>
        )
    }
})

export default Main
